/* 1417. 重新格式化字符串 */
/**
 * @param {string} s
 * @return {string}
 */
var reformat = function (s) {
	let str = '',
		num = ''
	let strIndex = 0,
		numIndex = 0
	for (let i = 0; i < s.length; i++) {
		if (+s[i] !== +s[i]) {
			str += s[i]
		} else {
			num += s[i]
		}
	}
	if (Math.abs(str.length - num.length) > 1) return ''
	let res = ''
	const flag = str.length > num.length
	debugger
	while (strIndex < str.length && numIndex < num.length) {
		if (flag) {
			res += str[strIndex]
			res += num[numIndex]
		} else {
			res += num[numIndex]
			res += str[strIndex]
		}
		strIndex += 1
		numIndex += 1
	}
	if (str.length !== num.length) {
		if (flag) {
			res += str[strIndex]
		} else {
			res += num[numIndex]
		}
	}
	return res
}
const res = reformat('a0b1c2')
console.log('reformat :<<', res)
